package com.example.wanbaqian.adapter;

import android.content.Context;
import android.view.View;

import com.example.wanbaqian.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/4/6 0006.
 * 发现活动适配器
 */

public class PayMoneyAdapter extends CommonAdapter<String> {
    private int chosePosition = 0;

    public PayMoneyAdapter(Context context, int layoutId, List<String> datas) {
        super(context, layoutId, datas);
    }

    @Override
    public void onViewHolderCreated(ViewHolder holder, View itemView) {
        super.onViewHolderCreated(holder, itemView);
        AutoUtils.autoSize(itemView);
    }


    public void setChoseposition(int position) {
        this.chosePosition = position;
        notifyDataSetChanged();
    }

    public int getChoseposition() {
        return chosePosition;
    }

    @Override
    protected void convert(ViewHolder holder, String s, final int position) {
        if (chosePosition == position)
            holder.setImageResource(R.id.iv_chose, R.drawable.ic_paychose_);
        else
            holder.setImageResource(R.id.iv_chose, R.drawable.ic_paychose);
        if (position == 0) {
            holder.setImageResource(R.id.iv_icon, R.drawable.ic_wx);
            holder.setText(R.id.tv_title, "微信支付还款");
        } else {
            holder.setImageResource(R.id.iv_icon, R.drawable.ic_yl);
            holder.setText(R.id.tv_title, "网银还款");
        }
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setChoseposition(position);
            }
        });
    }
}
